Analysis of EECA’s Energy End Use Data for New Zealand.
dataFile <- path.expand("~/Dropbox/data/EECA/eeud_data-2024-08-16-657.csv")
dt <- data.table::fread(dataFile)
The data gives total energy used (TJ) per year for different purposes by different sectors and by type.
For example, Figure 2.1 shows total energy use over time by sector group while Figure 2.2 shows the total by energy (fuel) type.
make_colPlot <- function(dt, xVar, yVar, fillVar, scaleVar){
p <- ggplot2::ggplot(dt, aes(x = get(xVar),
y = get(yVar),
fill = get(fillVar))) +
geom_col() +
scale_fill_discrete(name = scaleVar)
return(p)
}
plotDT <- dt[, .(Total_TJ = sum(TJ,na.rm = TRUE)),
keyby = .(SectorGroup, Period)]
make_colPlot(plotDT, "Period", "Total_TJ", "SectorGroup", "Sector") +
labs(x = "Year", y = "Total TJ")
Figure 2.1: Energy use by sector over time
message("2022 total")
## 2022 total
sum(plotDT[Period == 2022, Total_TJ])
## [1] 541085.4
plotDT <- dt[, .(Total_TJ = sum(TJ, na.rm = TRUE)),
keyby = .(FuelGroup, Period)]
make_colPlot(plotDT, "Period", "Total_TJ", "FuelGroup", "FuelGroup") +
labs(x = "Year", y = "Total TJ")
Figure 2.2: Energy use by fuel group over time
message("2022 total")
## 2022 total
sum(plotDT[Period == 2022, Total_TJ])
## [1] 541085.4
plotDT <- dt[Fuel %like% "Electricity", .(Total_TJ = sum(TJ, na.rm = TRUE)),
keyby = .(SectorGroup, Period)]
make_colPlot(plotDT, "Period", "Total_TJ", "SectorGroup", "SectorGroup") +
labs(x = "Year", y = "Total TJ")
Figure 2.3: Electricity use by sector over time
message("2022 total electricity")
## 2022 total electricity
sum(plotDT[Period == 2022, Total_TJ])
## [1] 138548.1
dt[, TJ_pc := 100 * TJ/sum(TJ, na.rm = TRUE), keyby = .(Period)]
res_dt <- dt[Sector %like% "Residential"]
res_dt[, TJ_res_pc := 100 * TJ/sum(TJ), keyby = .(Period)]
ggplot2::ggplot(res_dt,
aes(x = Period, y = TJ, fill = paste0(EndUseGroup, " - ", Fuel))) +
geom_col(position = "stack")
ggplot2::ggplot(res_dt,
aes(x = Period, y = TJ_res_pc, fill = paste0(EndUseGroup, " - ", Fuel))) +
geom_col(position = "stack")
t <- res_dt[Period == 2022, .(sum_TJ = sum(TJ),
TJ_pc = sum(TJ_pc, na.rm = TRUE),
TJ_res_pc = sum(TJ_res_pc)), keyby = .(EndUse, Fuel)]
knitr::kable(t, caption = "Summary for 2022", digits = 2)
| EndUse | Fuel | sum_TJ | TJ_pc | TJ_res_pc |
|---|---|---|---|---|
| Electronics and Other Electrical Uses | Electricity | 9588.26 | 1.77 | 11.72 |
| Intermediate Heat (100-300 C), Cooking | Electricity | 4361.85 | 0.81 | 5.33 |
| Intermediate Heat (100-300 C), Cooking | LPG | 42.37 | 0.01 | 0.05 |
| Intermediate Heat (100-300 C), Cooking | Natural Gas | 260.28 | 0.05 | 0.32 |
| Lighting | Electricity | 2567.67 | 0.47 | 3.14 |
| Low Temperature Heat (< 100 C), Dishwashers | Electricity | 686.23 | 0.13 | 0.84 |
| Low Temperature Heat (<100 C), Clothes Drying | Electricity | 339.58 | 0.06 | 0.42 |
| Low Temperature Heat (<100 C), Clothes Washing | Electricity | 644.21 | 0.12 | 0.79 |
| Low Temperature Heat (<100 C), Space Heating | Coal | 149.63 | 0.03 | 0.18 |
| Low Temperature Heat (<100 C), Space Heating | Electricity | 9487.37 | 1.75 | 11.60 |
| Low Temperature Heat (<100 C), Space Heating | LPG | 1224.15 | 0.23 | 1.50 |
| Low Temperature Heat (<100 C), Space Heating | Natural Gas | 3766.06 | 0.70 | 4.60 |
| Low Temperature Heat (<100 C), Space Heating | Wood | 5897.19 | 1.09 | 7.21 |
| Low Temperature Heat (<100 C), Water Heating | Electricity | 12486.23 | 2.31 | 15.26 |
| Low Temperature Heat (<100 C), Water Heating | LPG | 2522.05 | 0.47 | 3.08 |
| Low Temperature Heat (<100 C), Water Heating | Natural Gas | 2763.25 | 0.51 | 3.38 |
| Low Temperature Heat (<100 C), Water Heating | Wood | 1544.71 | 0.29 | 1.89 |
| Motive Power, Mobile | Diesel | 2683.58 | 0.50 | 3.28 |
| Motive Power, Mobile | Petrol | 14176.05 | 2.62 | 17.33 |
| Refrigeration | Electricity | 5519.90 | 1.02 | 6.75 |
| Space Cooling | Electricity | 1110.77 | 0.21 | 1.36 |
res_dt[EndUse %like% "Water", branzCat := "Water heating"]
res_dt[EndUse %like% "Space" , branzCat := "Space heating"]
res_dt[EndUse %like% "Cooking", branzCat := "Cooking"]
res_dt[Fuel %like% "Electricity" &
is.na(branzCat), branzCat := "Lighting, refrigeration & other electricity uses"]
bt <- res_dt[Period == 2022 & !is.na(branzCat), .(sum_TJ = sum(TJ),
TJ_pc= sum(TJ_pc, na.rm = TRUE),
TJ_res_pc = sum(TJ_res_pc)), keyby = .(branzCat)]
bt[, TJ_branzCat_pc := 100 * sum_TJ/sum(sum_TJ)]
knitr::kable(bt, caption = "Summary for 2022", digits = 2)
| branzCat | sum_TJ | TJ_pc | TJ_res_pc | TJ_branzCat_pc |
|---|---|---|---|---|
| Cooking | 4664.50 | 0.86 | 5.70 | 7.18 |
| Lighting, refrigeration & other electricity uses | 19345.85 | 3.58 | 23.64 | 29.78 |
| Space heating | 21635.17 | 4.00 | 26.44 | 33.30 |
| Water heating | 19316.24 | 3.57 | 23.61 | 29.73 |
dt[, TJ_fuel_pc := 100 * TJ/sum(TJ, na.rm = TRUE), keyby = .(Fuel, Period)]
res_elec_dt <- dt[Fuel %like% "Electricity" &
Sector %like% "Residential"]
ggplot2::ggplot(res_elec_dt,
aes(x = Period, y = TJ, fill = EndUseGroup)) +
geom_col(position = "stack")
p <- ggplot2::ggplot(res_elec_dt[EndUse %like% "Heat"],
aes(x = Period, y = TJ,
fill = Technology
)) +
geom_col(position = "stack") +
theme(legend.position = "bottom")
plotly::ggplotly(p)
Figure 3.1: Electricity used for heat
resElec_2022_pc <- sum(res_elec_dt[Period == 2022, TJ_fuel_pc])
resElec_2022 <- sum(res_elec_dt[Period == 2022, TJ])
resElec_2022_spaceHeat <- sum(res_elec_dt[Period == 2022 &
EndUse %like% "Space Heating", TJ])
resElec_2022_spaceHeat_pc <- sum(res_elec_dt[Period == 2022 &
EndUse %like% "Space Heating", TJ_fuel_pc])
resElec_2022_dt <- res_elec_dt[Period == 2022, .(total_TJ = sum(TJ, na.rm = TRUE),
total_pc = sum(TJ_pc, na.rm = TRUE),
total_elec_pc = sum(TJ_fuel_pc, na.rm = TRUE)),
keyby = .(Sector, EndUseGroup, EndUse)]
resElec_2022_dt[, resElec_pc := 100 * total_TJ/sum(total_TJ)]
knitr::kable(resElec_2022_dt, digits = 2, caption = "2022 residential electricity use summary")
| Sector | EndUseGroup | EndUse | total_TJ | total_pc | total_elec_pc | resElec_pc |
|---|---|---|---|---|---|---|
| Residential | Electronics and Lighting | Electronics and Other Electrical Uses | 9588.26 | 1.77 | 6.92 | 20.49 |
| Residential | Electronics and Lighting | Lighting | 2567.67 | 0.47 | 1.85 | 5.49 |
| Residential | Heating/Cooling | Intermediate Heat (100-300 C), Cooking | 4361.85 | 0.81 | 3.15 | 9.32 |
| Residential | Heating/Cooling | Low Temperature Heat (< 100 C), Dishwashers | 686.23 | 0.13 | 0.50 | 1.47 |
| Residential | Heating/Cooling | Low Temperature Heat (<100 C), Clothes Drying | 339.58 | 0.06 | 0.25 | 0.73 |
| Residential | Heating/Cooling | Low Temperature Heat (<100 C), Clothes Washing | 644.21 | 0.12 | 0.46 | 1.38 |
| Residential | Heating/Cooling | Low Temperature Heat (<100 C), Space Heating | 9487.37 | 1.75 | 6.85 | 20.28 |
| Residential | Heating/Cooling | Low Temperature Heat (<100 C), Water Heating | 12486.23 | 2.31 | 9.01 | 26.68 |
| Residential | Heating/Cooling | Refrigeration | 5519.90 | 1.02 | 3.98 | 11.80 |
| Residential | Heating/Cooling | Space Cooling | 1110.77 | 0.21 | 0.80 | 2.37 |
2022
ggplot2::ggplot(res_elec_dt[EndUse %like% "Space Heat"], aes(x = Period,
y = TJ,
colour = Technology))+
geom_line()
# theme(legend.position = "bottom") +
# guides(colour=guide_legend(ncol=1))
ggplot2::ggplot(res_elec_dt[EndUse %like% "Space Heat"], aes(x = Period,
y = TJ_fuel_pc,
colour = Technology))+
geom_line() +
labs(y = "% total electricity")
res_elec_dt[, resElec_pc := 100 * TJ/sum(TJ), keyby = .(Period)]
ggplot2::ggplot(res_elec_dt[EndUse %like% "Space Heat"], aes(x = Period,
y = resElec_pc,
colour = Technology))+
geom_line() +
labs(y = "% residential electricity")
Oh. Well that’s interesting… The % of residential electrity used for these two types of heat have never been updated…